package org.stu.tp.testCases.contact;

import org.stu.tp.core.DefaultTestCase;
import org.stu.tp.dao.TeamDao;
import org.stu.tp.dto.Team;
import org.stu.tp.util.UtilTools;

public class TestTeam extends DefaultTestCase {
	TeamAction userAC = new TeamAction();

	/**
	 * Add team with team1.
	 */
	public void testAddOneTeam() {
		Team team = TeamDao.getTeam("team1");

		// login and access to contact book.
		userAC.loginAndAccessContactBook(this.getSelenium());
		// Add one team.
		userAC.clickAddTeamButton(this.getSelenium());
		userAC.setName(this.getSelenium(), team.getTeamName());
		userAC.clickSaveButton(this.getSelenium());
		selenium.getConfirmation();
		userAC.waitForPageToLoad(this.getSelenium());
		// assert
		assertNotNull(userAC
				.getTeamPath(this.getSelenium(), team.getTeamName()));
	}

	public void testEditOneTeam() {
		Team team = TeamDao.getTeam("team1");
		String teamNewName="team"+UtilTools.getCurrentTime();

		// login and access to contact book.
		userAC.loginAndAccessContactBook(this.getSelenium());
		
		userAC.selectTeam(this.getSelenium(), team.getTeamName());
		userAC.clickEditButton(this.getSelenium());
		userAC.setName(this.getSelenium(), teamNewName);
		userAC.clickSaveButton(this.getSelenium());
		selenium.getConfirmation();
		userAC.waitForPageToLoad(this.getSelenium());
		assertNotNull(userAC
				.getTeamPath(this.getSelenium(), teamNewName));
		assertNull(userAC
				.getTeamPath(this.getSelenium(), team.getTeamName()));
		userAC.deleteOneTeam(this.getSelenium(), teamNewName);
	}
	

}
